package com.gitee.hermer.engine.jars.dependent.xa.datasource.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import com.gitee.hermer.boot.jee.commons.number.IntegerUtils;
import com.gitee.hermer.boot.jee.commons.number.NumberUtils;
import com.gitee.hermer.boot.jee.commons.utils.StringUtils;
import com.gitee.hermer.engine.jars.core.domain.EngineConstant;
import com.gitee.hermer.engine.jars.dependent.dsm.domain.EngineProperties;

@PropertySource(EngineConstant.ENGINE_CONFIG_PROPERTIES_CLASS_PATH)
@Component
public class XADataSourceProperties extends EngineProperties{
	@Value(EngineConstant.PROPERTIES_KEY_ENGINE_CONFIG_XA_DATASOURCE_BORROW_TIMEOUT)
	private  Integer borrowConnectionTimeout; 
	@Value(EngineConstant.PROPERTIES_KEY_ENGINE_CONFIG_XA_DATASOURCE_TEST_QUERY)
	private  String testQuery;
	@Value(EngineConstant.PROPERTIES_KEY_ENGINE_CONFIG_XA_DATASOURCE_POOL_SIZE)
	private  Integer poolSize;
	@Value(EngineConstant.PROPERTIES_KEY_ENGINE_CONFIG_XA_DATASOURCE_MAIN_INTERVAL)
	private  Integer maintenanceInterval;
	@Value(EngineConstant.PROPERTIES_KEY_ENGINE_CONFIG_XA_DATASOURCE_REAP_TIMEOUT)
	private  Integer reapTimeout;
	
	@Value(EngineConstant.PROPERTIES_KEY_ENGINE_CONFIG_XA_DATASOURCE_DRUID_FILTERS)
	private  String filters;
	
	public String getFilters() {
		return StringUtils.defaultIfEmpty(filters, EngineConstant.DEFAULT_VALUES_ENGINE_CONFIG_XA_DATASOURCE_DRUID_FILTERS);
	}
	public void setFilters(String filters) {
		this.filters = filters;
	}
	
	
	public Integer getBorrowConnectionTimeout() {
		return IntegerUtils.defaultIfZero(borrowConnectionTimeout, EngineConstant.DEFAULT_VALUES_ENGINE_CONFIG_XA_DATASOURCE_BORROW_TIMEOUT);
	}
	public void setBorrowConnectionTimeout(Integer borrowConnectionTimeout) {
		this.borrowConnectionTimeout = borrowConnectionTimeout;
	}
	public String getTestQuery() {
		return StringUtils.defaultIfEmpty(testQuery, EngineConstant.DEFAULT_VALUES_ENGINE_CONFIG_XA_DATASOURCE_TEST_QUERY);
	}
	public void setTestQuery(String testQuery) {
		this.testQuery = testQuery;
	}
	public Integer getPoolSize() {
		return IntegerUtils.defaultIfZero(poolSize, EngineConstant.DEFAULT_VALUES_ENGINE_CONFIG_THREAD_POOL_SIZE);
	}
	public void setPoolSize(Integer poolSize) {
		this.poolSize = poolSize;
	}
	public Integer getMaintenanceInterval() {
		return IntegerUtils.defaultIfZero(maintenanceInterval, EngineConstant.DEFAULT_VALUES_ENGINE_CONFIG_XA_DATASOURCE_MAIN_INTERVAL);
	}
	public void setMaintenanceInterval(Integer maintenanceInterval) {
		this.maintenanceInterval = maintenanceInterval;
	}
	public Integer getReapTimeout() {
		return IntegerUtils.defaultIfZero(reapTimeout, EngineConstant.DEFAULT_VALUES_ENGINE_CONFIG_XA_DATASOURCE_REAP_TIMEOUT);
	}
	public void setReapTimeout(Integer reapTimeout) {
		this.reapTimeout = reapTimeout;
	}
	
	
	
	
}
